package org.wevil.repo.witcher3;

import org.wevil.entity.witcher3.Witcher3Alchemy;
import org.wevil.repo.BaseRepo;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

public interface Witcher3AlchemyRepo extends BaseRepo<Witcher3Alchemy, Integer> {

    @Modifying
    @Query("update Witcher3Alchemy t set " +
            "t.nameEn = case when :#{#entity.nameEn} is null then t.nameEn else :#{#entity.nameEn} end, " +
            "t.nameCn = case when :#{#entity.nameCn} is null then t.nameCn else :#{#entity.nameCn} end, " +
            "t.type = case when :#{#entity.type} is null then t.type else :#{#entity.type} end, " +
            "t.descEn = case when :#{#entity.descEn} is null then t.descEn else :#{#entity.descEn} end, " +
            "t.descCn = case when :#{#entity.descCn} is null then t.descCn else :#{#entity.descCn} end, " +
            "t.price = case when :#{#entity.price} is null then t.price else :#{#entity.price} end, " +
            "t.img = case when :#{#entity.img} is null then t.img else :#{#entity.img} end " +
            "where t.id = :#{#entity.id}")
    void update(Witcher3Alchemy entity);
}
